<?php

use think\migration\Seeder;

class AirQualityStationAqiForecastDayData extends Seeder
{

    /**
     * 空气质量-站点-AQI-预报值-天 数据
     */
    public function run()
    {
        $table = $this->table('air_quality_station_aqi_forecast_day');

        $rows = [];
        $num  = 7;
        $i    = 0;
        while ($num > 0) {
            $typeArr    = ['PM2.5', 'PM10', 'SO2', 'NO2', 'CO', 'O3'];
            $randomKeys = array_rand($typeArr);

            $conditionArr  = ['优', '良', '轻度', '中度', '重度', '严重'];
            $conditionKeys = array_rand($conditionArr);

            //绿色，黄色，橙色，红色，紫色，褐红色
            $colorArr  = ['green', 'yellow', 'orange', 'red', 'purple', 'maroon'];
            $colorKeys = array_rand($colorArr);
            $rows[]    = [
                //step1:基本信息
                'region_id'    => '53',                    //区域ID
                'station_id'   => mt_rand(0, 5),           //站点ID
                //step2:时间
                'predict_time' => date('Y-m-d', time() + 3600 * $i),   //预报时间-7天
                'publish_time' => date('Y-m-d'),   //发布时间-7天
                //step3:六参
                //PM10
                'pm10'         => mt_rand(0, 200),
                'pm10_level'   => $conditionArr[$conditionKeys],
                'pm10_percent' => mt_rand(30, 100),
                'pm10_color'   => $colorArr[$colorKeys],
                'pm10_iaqi'    => mt_rand(0, 100),

                //PM25
                'pm25'         => mt_rand(0, 200),
                'pm25_level'   => $conditionArr[$conditionKeys],
                'pm25_percent' => mt_rand(30, 100),
                'pm25_color'   => $colorArr[$colorKeys],
                'pm25_iaqi'    => mt_rand(0, 100),
                //二氧化硫
                'so2'          => mt_rand(0, 200),
                'so2_level'    => $conditionArr[$conditionKeys],
                'so2_percent'  => mt_rand(30, 100),
                'so2_color'    => $colorArr[$colorKeys],
                'so2_iaqi'     => mt_rand(0, 100),
                //二氧化氮
                'no2'          => mt_rand(0, 200),
                'no2_level'    => $conditionArr[$conditionKeys],
                'no2_percent'  => mt_rand(30, 100),
                'no2_color'    => $colorArr[$colorKeys],
                'no2_iaqi'     => mt_rand(0, 100),
                //一氧化碳
                'co'           => mt_rand(0, 200),
                'co_level'     => $conditionArr[$conditionKeys],
                'co_percent'   => mt_rand(30, 100),
                'co_color'     => $colorArr[$colorKeys],
                'co_iaqi'      => mt_rand(0, 100),
                //臭氧
                'o3'           => mt_rand(0, 200),
                'o3_level'     => $conditionArr[$conditionKeys],
                'o3_percent'   => mt_rand(30, 100),
                'o3_color'     => $colorArr[$colorKeys],
                'o3_iaqi'      => mt_rand(0, 100),

                //step4:AQI
                'aqi'          => mt_rand(0, 200),          //aqi
                'aqi_level'    => $conditionArr[$conditionKeys],   //aqi污染情况

                //step7:系统时间
                'create_time'  => date('Y-m-d H:i:s', time()), //插入时间
            ];
            $num--;
            $i++;
        }

        $table->insert($rows)->save();
    }
}